package com.xie.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xiefeixiang
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对redisson的使用都是通过RedissonClient对象
     *
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    RedissonClient redisson() {
        Config config = new Config();
        //rediss 代表安全连接
        config.useSingleServer().setAddress("redis://192.168.56.10:6379");
        //多节点模式
//        config.useClusterServers().addNodeAddress();
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }

}
